/* Generate a package from bfd.h definitions
   Copyright 2012, 2014 Free Software Foundation, Inc.
   Contributed by Stephane Carrez (Stephane.Carrez@gmail.com)

This file is part of BfdAda.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */

#include "config.h"
#include <stdio.h>
#include "bfd.h"

/**
 * If a BFD define does not exist, pretend the flag is 0.
 * An Ada program can check conditionally for the availablility
 * of the flag by checking that the definition is not 0.
 */
#ifndef SEC_ELF_REVERSE_COPY
# define SEC_ELF_REVERSE_COPY 0
#endif

#ifndef SEC_COFF_NOREAD
# define SEC_COFF_NOREAD 0
#endif

#ifndef BSF_RELC
# define BSF_RELC 0
#endif

#ifndef BSF_SRELC
# define BSF_SRELC 0
#endif

#ifndef BSF_SYNTHETIC
# define BSF_SYNTHETIC 0
#endif

#ifndef BSF_GNU_INDIRECT_FUNCTION
# define BSF_GNU_INDIRECT_FUNCTION 0
#endif

#ifndef BSF_GNU_UNIQUE
# define BSF_GNU_UNIQUE 0
#endif

#ifndef BFD_DETERMINISTIC_OUTPUT
# define BFD_DETERMINISTIC_OUTPUT 0
#endif

#ifndef BFD_COMPRESS
# define BFD_COMPRESS 0
#endif

#ifndef BFD_DECOMPRESS
# define BFD_DECOMPRESS 0
#endif

#ifndef BFD_PLUGIN
# define BFD_PLUGIN 0
#endif

#ifndef HAS_LOAD_PAGE
# define HAS_LOAD_PAGE 0
#endif

int main(void)
{
  printf("--  Generated by bfdgen.c from system bfd.h\n");
  
  printf("package Bfd.Constants is\n");
  printf("\n");

  printf("   LINKER_OPTIONS : constant String := ");
#ifdef HAVE_LIB_DL
  printf("ASCII.NUL & ");
  printf("\"-ldl\"");
#endif

#ifdef HAVE_LIB_INTL
  printf("ASCII.NUL & ");
  printf("\"-lintl\"");
#endif

#if !defined(HAVE_LIB_DL) && !defined(HAVE_LIB_INTL)
  printf("\"\"");
#endif
  printf(";\n");

  printf("\n");
  printf("   SEC_NO_FLAGS                      : constant Section_Flags := 16#%04x#;\n", SEC_NO_FLAGS);
  printf("   SEC_ALLOC                         : constant Section_Flags := 16#%04x#;\n", SEC_ALLOC);
  printf("   SEC_LOAD                          : constant Section_Flags := 16#%04x#;\n", SEC_LOAD);
  printf("   SEC_RELOC                         : constant Section_Flags := 16#%04x#;\n", SEC_RELOC);
  printf("   SEC_READONLY                      : constant Section_Flags := 16#%04x#;\n", SEC_READONLY);
  printf("   SEC_CODE                          : constant Section_Flags := 16#%04x#;\n", SEC_CODE);
  printf("   SEC_DATA                          : constant Section_Flags := 16#%04x#;\n", SEC_DATA);
  printf("   SEC_ROM                           : constant Section_Flags := 16#%04x#;\n", SEC_ROM);
  printf("   SEC_CONSTRUCTOR                   : constant Section_Flags := 16#%04x#;\n", SEC_CONSTRUCTOR);
  printf("   SEC_HAS_CONTENTS                  : constant Section_Flags := 16#%04x#;\n", SEC_HAS_CONTENTS);
  printf("   SEC_NEVER_LOAD                    : constant Section_Flags := 16#%04x#;\n", SEC_NEVER_LOAD);
  printf("   SEC_THREAD_LOCAL                  : constant Section_Flags := 16#%04x#;\n", SEC_THREAD_LOCAL);
  printf("   SEC_HAS_GOT_REF                   : constant Section_Flags := 16#%04x#;\n", SEC_HAS_GOT_REF);
  printf("   SEC_IS_COMMON                     : constant Section_Flags := 16#%04x#;\n", SEC_IS_COMMON);
  printf("   SEC_DEBUGGING                     : constant Section_Flags := 16#%04x#;\n", SEC_DEBUGGING);
  printf("   SEC_IN_MEMORY                     : constant Section_Flags := 16#%04x#;\n", SEC_IN_MEMORY);
  printf("   SEC_EXCLUDE                       : constant Section_Flags := 16#%04x#;\n", SEC_EXCLUDE);
  printf("   SEC_SORT_ENTRIES                  : constant Section_Flags := 16#%04x#;\n", SEC_SORT_ENTRIES);
  printf("   SEC_LINK_ONCE                     : constant Section_Flags := 16#%04x#;\n", SEC_LINK_ONCE);
  printf("   SEC_LINK_DUPLICATES               : constant Section_Flags := 16#%04x#;\n", SEC_LINK_DUPLICATES);
  printf("   SEC_LINK_DUPLICATES_DISCARD       : constant Section_Flags := 16#%04x#;\n", SEC_LINK_DUPLICATES_DISCARD);
  printf("   SEC_LINK_DUPLICATES_ONE_ONLY      : constant Section_Flags := 16#%04x#;\n", SEC_LINK_DUPLICATES_ONE_ONLY);
  printf("   SEC_LINK_DUPLICATES_SAME_SIZE     : constant Section_Flags := 16#%04x#;\n", SEC_LINK_DUPLICATES_SAME_SIZE);
  printf("   SEC_LINK_DUPLICATES_SAME_CONTENTS : constant Section_Flags := 16#%04x#;\n", SEC_LINK_DUPLICATES_SAME_CONTENTS);
  printf("   SEC_LINKER_CREATED                : constant Section_Flags := 16#%04x#;\n", SEC_LINKER_CREATED);
  printf("   SEC_KEEP                          : constant Section_Flags := 16#%04x#;\n", SEC_KEEP);
  printf("   SEC_SMALL_DATA                    : constant Section_Flags := 16#%04x#;\n", SEC_SMALL_DATA);
  printf("   SEC_MERGE                         : constant Section_Flags := 16#%04x#;\n", SEC_MERGE);
  printf("   SEC_STRINGS                       : constant Section_Flags := 16#%04x#;\n", SEC_STRINGS);
  printf("   SEC_GROUP                         : constant Section_Flags := 16#%04x#;\n", SEC_GROUP);
  printf("   SEC_COFF_SHARED_LIBRARY           : constant Section_Flags := 16#%04x#;\n", SEC_COFF_SHARED_LIBRARY);
  printf("   SEC_ELF_REVERSE_COPY              : constant Section_Flags := 16#%04x#;\n", SEC_ELF_REVERSE_COPY);
  printf("   SEC_COFF_SHARED                   : constant Section_Flags := 16#%04x#;\n", SEC_COFF_SHARED);
  printf("   SEC_TIC54X_BLOCK                  : constant Section_Flags := 16#%04x#;\n", SEC_TIC54X_BLOCK);
  printf("   SEC_TIC54X_CLINK                  : constant Section_Flags := 16#%04x#;\n", SEC_TIC54X_CLINK);
  printf("   SEC_COFF_NOREAD                   : constant Section_Flags := 16#%04x#;\n", SEC_COFF_NOREAD);
  printf("\n");

  printf("   BSF_NO_FLAGS                : constant Symbol_Flags := 16#%04x#;\n", BSF_NO_FLAGS);
  printf("   BSF_LOCAL                   : constant Symbol_Flags := 16#%04x#;\n", BSF_LOCAL);
  printf("   BSF_GLOBAL                  : constant Symbol_Flags := 16#%04x#;\n", BSF_GLOBAL);
  printf("   BSF_DEBUGGING               : constant Symbol_Flags := 16#%04x#;\n", BSF_DEBUGGING);
  printf("   BSF_FUNCTION                : constant Symbol_Flags := 16#%04x#;\n", BSF_FUNCTION);
  printf("   BSF_KEEP                    : constant Symbol_Flags := 16#%04x#;\n", BSF_KEEP);
  printf("   BSF_KEEP_G                  : constant Symbol_Flags := 16#%04x#;\n", BSF_KEEP_G);
  printf("   BSF_WEAK                    : constant Symbol_Flags := 16#%04x#;\n", BSF_WEAK);
  printf("   BSF_SECTION_SYM             : constant Symbol_Flags := 16#%04x#;\n", BSF_SECTION_SYM);
  printf("   BSF_OLD_COMMON              : constant Symbol_Flags := 16#%04x#;\n", BSF_OLD_COMMON);
  printf("   BSF_NOT_AT_END              : constant Symbol_Flags := 16#%04x#;\n", BSF_NOT_AT_END);
  printf("   BSF_CONSTRUCTOR             : constant Symbol_Flags := 16#%04x#;\n", BSF_CONSTRUCTOR);
  printf("   BSF_WARNING                 : constant Symbol_Flags := 16#%04x#;\n", BSF_WARNING);
  printf("   BSF_INDIRECT                : constant Symbol_Flags := 16#%04x#;\n", BSF_INDIRECT);
  printf("   BSF_FILE                    : constant Symbol_Flags := 16#%04x#;\n", BSF_FILE);
  printf("   BSF_DYNAMIC                 : constant Symbol_Flags := 16#%04x#;\n", BSF_DYNAMIC);
  printf("   BSF_OBJECT                  : constant Symbol_Flags := 16#%04x#;\n", BSF_OBJECT);
  printf("   BSF_DEBUGGING_RELOC         : constant Symbol_Flags := 16#%04x#;\n", BSF_DEBUGGING_RELOC);
  printf("   BSF_THREAD_LOCAL            : constant Symbol_Flags := 16#%04x#;\n", BSF_THREAD_LOCAL);
  printf("   BSF_RELC                    : constant Symbol_Flags := 16#%04x#;\n", BSF_RELC);
  printf("   BSF_SRELC                   : constant Symbol_Flags := 16#%04x#;\n", BSF_SRELC);
  printf("   BSF_SYNTHETIC               : constant Symbol_Flags := 16#%04x#;\n", BSF_SYNTHETIC);
  printf("   BSF_GNU_INDIRECT_FUNCTION   : constant Symbol_Flags := 16#%04x#;\n", BSF_GNU_INDIRECT_FUNCTION);
  printf("   BSF_GNU_UNIQUE              : constant Symbol_Flags := 16#%04x#;\n", BSF_GNU_UNIQUE);
  printf("\n");

  printf("   BFD_NO_FLAGS                : constant File_Flags := 16#%04x#;\n", BFD_NO_FLAGS);
  printf("   HAS_RELOC                   : constant File_Flags := 16#%04x#;\n", HAS_RELOC);
  printf("   EXEC_P                      : constant File_Flags := 16#%04x#;\n", EXEC_P);
  printf("   HAS_LINENO                  : constant File_Flags := 16#%04x#;\n", HAS_LINENO);
  printf("   HAS_DEBUG                   : constant File_Flags := 16#%04x#;\n", HAS_DEBUG);
  printf("   HAS_SYMS                    : constant File_Flags := 16#%04x#;\n", HAS_SYMS);
  printf("   HAS_LOCALS                  : constant File_Flags := 16#%04x#;\n", HAS_LOCALS);
  printf("   DYNAMIC                     : constant File_Flags := 16#%04x#;\n", DYNAMIC);
  printf("   WP_TEXT                     : constant File_Flags := 16#%04x#;\n", WP_TEXT);
  printf("   D_PAGED                     : constant File_Flags := 16#%04x#;\n", D_PAGED);
  printf("   BFD_IS_RELAXABLE            : constant File_Flags := 16#%04x#;\n", BFD_IS_RELAXABLE);
  printf("   BFD_TRADITIONAL_FORMAT      : constant File_Flags := 16#%04x#;\n", BFD_TRADITIONAL_FORMAT);
  printf("   BFD_IN_MEMORY               : constant File_Flags := 16#%04x#;\n", BFD_IN_MEMORY);
  printf("   HAS_LOAD_PAGE               : constant File_Flags := 16#%04x#;\n", HAS_LOAD_PAGE);
  printf("   BFD_LINKER_CREATED          : constant File_Flags := 16#%04x#;\n", BFD_LINKER_CREATED);
  printf("   BFD_DETERMINISTIC_OUTPUT    : constant File_Flags := 16#%04x#;\n", BFD_DETERMINISTIC_OUTPUT);
  printf("   BFD_COMPRESS                : constant File_Flags := 16#%04x#;\n", BFD_COMPRESS);
  printf("   BFD_DECOMPRESS              : constant File_Flags := 16#%04x#;\n", BFD_DECOMPRESS);
  printf("   BFD_PLUGIN                  : constant File_Flags := 16#%04x#;\n", BFD_PLUGIN);

  printf("end Bfd.Constants;\n");
  return 0;
}
